package com.goddess.yeecolor.view;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.goddess.yeecolor.R;

/**
 * 弹框
 */
public class LoadingDialog extends Dialog implements View.OnClickListener{

    private static final int MY_PERMISSIONS_REQUEST_CALL_PHONE = 1;
    private int tag;
    private String phone;
    public TextView cancal,call,content;
    private LinearLayout mLinear;
    private Activity activity;
    private String setPhone;
    public LoadingDialog(Context context,Activity activity,String phone,int tag) {
        super(context);
        this.activity=activity;
        this.setPhone=phone;
        this.tag=tag;
    }

    public LoadingDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    protected LoadingDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_call);
        content= (TextView) findViewById(R.id.call_content);
        cancal= (TextView) findViewById(R.id.call_dimess);
        call= (TextView) findViewById(R.id.call);
        content.setText(setPhone);
        mLinear= (LinearLayout) findViewById(R.id.LinearLayout);
        mLinear.getBackground().setAlpha(210);
        call.setOnClickListener(this);
        cancal.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int id=view.getId();
        switch (id){
            case R.id.call_dimess:
                dismiss();
                break;
            case R.id.call:
                if (tag==1){
                    Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" +setPhone));
                    //启动
                    activity.startActivity(phoneIntent);
                }
                else if (tag==2){

                }
                dismiss();
                break;
        }
    }


}
